﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Security;
using System.IO;


public partial class admin_reports_reports : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Roles.IsUserInRole("Role_Uni_Admin"))
        {
            int uni_id = ACSService.getAdminUni(Membership.GetUser().ProviderUserKey.ToString());
            UniID.Value = Convert.ToString(uni_id);
            uniLabel.Text = ACSService.getUniName(uni_id);
        }
        else if (Roles.IsUserInRole("Role_Super_Admin"))
        {
            uniLabel.Text = "Global";
        }
       
    }

    public virtual void VerifyRenderingInServerForm(Control control)
    {

    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        GridView grw = new GridView();

        grw.DataSource = ACSService.getAllMembers(int.Parse(UniID.Value));
        grw.DataBind();

        string style = @"<style> .text { mso-number-format:\@; } </script> ";
        Response.ClearContent();
        Response.AddHeader("content-disposition", "attachment; filename=Report.xls");
        Response.ContentType = "application/excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        grw.RenderControl(htw);
        // Style is added dynamically
        Response.Write(style);
        Response.Write(sw.ToString());
        Response.End();



    }
}